home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 008a / perl40_2.zip / STR.H < prev    next >
C/C++ Source or Header  |  1991-11-28  |  5KB  |  158 lines

  1. /* $RCSfile: str.h,v $$Revision: 4.0.1.3 $$Date: 91/11/05 18:41:47 $
  2.  *
  3.  *    Copyright (c) 1991, Larry Wall
  4.  *
  5.  *    You may distribute under the terms of either the GNU General Public
  6.  *    License or the Artistic License, as specified in the README file.
  7.  *
  8.  * $Log:    str.h,v $
  9.  * Revision 4.0.1.3  91/11/05  18:41:47  lwall
  10.  * patch11: random cleanup
  11.  * patch11: solitary subroutine references no longer trigger typo warnings
  12.  *
  13.  * Revision 4.0.1.2  91/06/07  11:58:33  lwall
  14.  * patch4: new copyright notice
  15.  *
  16.  * Revision 4.0.1.1  91/04/12  09:16:12  lwall
  17.  * patch1: you may now use "die" and "caller" in a signal handler
  18.  *
  19.  * Revision 4.0  91/03/20  01:40:04  lwall
  20.  * 4.0 baseline.
  21.  *
  22.  */
  23.  
  24.  
  25. struct string {
  26.     char *    str_ptr;    /* pointer to malloced string */
  27.     STRLEN    str_len;    /* allocated size */
  28.     union {
  29.     double    str_nval;    /* numeric value, if any */
  30.     STAB    *str_stab;    /* magic stab for magic "key" string */
  31.     long    str_useful;    /* is this search optimization effective? */
  32.     ARG    *str_args;    /* list of args for interpreted string */
  33.     HASH    *str_hash;    /* string represents an assoc array (stab?) */
  34.     ARRAY    *str_array;    /* string represents an array */
  35.     CMD    *str_cmd;    /* command for this source line */
  36.     } str_u;
  37.     STRLEN    str_cur;    /* length of str_ptr as a C string */
  38.     STR        *str_magic;    /* while free, link to next free str */
  39.                 /* while in use, ptr to "key" for magic items */
  40.     unsigned char str_pok;    /* state of str_ptr */
  41.     unsigned char str_nok;    /* state of str_nval */
  42.     unsigned char str_rare;    /* used by search strings */
  43.     unsigned char str_state;    /* one of SS_* below */
  44.                 /* also used by search strings for backoff */
  45. #ifdef TAINT
  46.     bool    str_tainted;    /* 1 if possibly under control of $< */
  47. #endif
  48. };
  49.  
  50.  
  51. struct stab {    /* should be identical, except for str_ptr */
  52.     STBP *    str_ptr;    /* pointer to malloced string */
  53.     STRLEN    str_len;    /* allocated size */
  54.     union {
  55.     double    str_nval;    /* numeric value, if any */
  56.     STAB    *str_stab;    /* magic stab for magic "key" string */
  57.     long    str_useful;    /* is this search optimization effective? */
  58.     ARG    *str_args;    /* list of args for interpreted string */
  59.     HASH    *str_hash;    /* string represents an assoc array (stab?) */
  60.     ARRAY    *str_array;    /* string represents an array */
  61.     CMD    *str_cmd;    /* command for this source line */
  62.     } str_u;
  63.     STRLEN    str_cur;    /* length of str_ptr as a C string */
  64.     STR        *str_magic;    /* while free, link to next free str */
  65.                 /* while in use, ptr to "key" for magic items */
  66.     unsigned char str_pok;    /* state of str_ptr */
  67.     unsigned char str_nok;    /* state of str_nval */
  68.     unsigned char str_rare;    /* used by search strings */
  69.     unsigned char str_state;    /* one of SS_* below */
  70.                 /* also used by search strings for backoff */
  71. #ifdef TAINT
  72.     bool    str_tainted;    /* 1 if possibly under control of $< */
  73. #endif
  74. };
  75.  
  76.  
  77. /* some extra info tacked to some lvalue strings */
  78.  
  79.  
  80. struct lstring {
  81.     struct string lstr;
  82.     STRLEN    lstr_offset;
  83.     STRLEN    lstr_len;
  84. };
  85.  
  86.  
  87. /* These are the values of str_pok:        */
  88. #define SP_VALID    1    /* str_ptr is valid */
  89. #define SP_FBM        2    /* string was compiled for fbm search */
  90. #define SP_STUDIED    4    /* string was studied */
  91. #define SP_CASEFOLD    8    /* case insensitive fbm search */
  92. #define SP_INTRP    16    /* string was compiled for interping */
  93. #define SP_TAIL        32    /* fbm string is tail anchored: /foo$/  */
  94. #define SP_MULTI    64    /* symbol table entry probably isn't a typo */
  95. #define SP_TEMP        128    /* string slated to die, so can be plundered */
  96.  
  97.  
  98. #define Nullstr Null(STR*)
  99.  
  100.  
  101. /* These are the values of str_state:        */
  102. #define SS_NORM        0    /* normal string */
  103. #define SS_INCR        1    /* normal string, incremented ptr */
  104. #define SS_SARY        2    /* array on save stack */
  105. #define SS_SHASH    3    /* associative array on save stack */
  106. #define SS_SINT        4    /* integer on save stack */
  107. #define SS_SLONG    5    /* long on save stack */
  108. #define SS_SSTRP    6    /* STR* on save stack */
  109. #define SS_SHPTR    7    /* HASH* on save stack */
  110. #define SS_SNSTAB    8    /* non-stab on save stack */
  111. #define SS_SCSV        9    /* callsave structure on save stack */
  112. #define SS_SAPTR    10    /* ARRAY* on save stack */
  113. #define SS_HASH        253    /* carrying an hash */
  114. #define SS_ARY        254    /* carrying an array */
  115. #define SS_FREE        255    /* in free list */
  116. /* str_state may have any value 0-255 when used to hold fbm pattern, in which */
  117. /* case it indicates offset to rarest character in screaminstr key */
  118.  
  119.  
  120. /* the following macro updates any magic values this str is associated with */
  121.  
  122.  
  123. #ifdef TAINT
  124. #define STABSET(x) \
  125.     (x)->str_tainted |= tainted; \
  126.     if ((x)->str_magic) \
  127.     stabset((x)->str_magic,(x))
  128. #else
  129. #define STABSET(x) \
  130.     if ((x)->str_magic) \
  131.     stabset((x)->str_magic,(x))
  132. #endif
  133.  
  134.  
  135. #define STR_SSET(dst,src) if (dst != src) str_sset(dst,src)
  136.  
  137.  
  138. EXT STR **tmps_list;
  139. EXT int tmps_max INIT(-1);
  140. EXT int tmps_base INIT(-1);
  141.  
  142.  
  143. char *str_2ptr();
  144. double str_2num();
  145. STR *str_mortal();
  146. STR *str_2mortal();
  147. STR *str_make();
  148. STR *str_nmake();
  149. STR *str_smake();
  150. int str_cmp();
  151. int str_eq();
  152. void str_magic();
  153. void str_insert();
  154. STRLEN str_len();
  155.  
  156.  
  157. #define MULTI    (3)
  158.